<script setup lang='ts'>
// const {data:info} = await useFetch("/api/detail");
const serialNo = useRoute().params.id;
const { data: res } = await useServerRequest<{ data: any }>(
  `article/${serialNo}/detail`,
  {
    method: "POST",
    body: { serialNo },
  }
);

const  {data:siteInfo} = await useServerRequest<{ data: any }>("sites/info", {
  method: "POST",
  body: {},
});

useHead({
  link:[
  { rel: 'shortcut icon', href: siteInfo.value.result.logoUrl},
    { rel: 'apple-touch-icon', href: siteInfo.value.result.logoUrl },
    {ref:'icon',type:'image/x-icon',href:siteInfo.value.result.logoUrl,'data-rh':true}
],
  meta:[{name:'twitter:card',content:'summary_large_image'}]
})


const info = res.value?.result;

useSeoMeta({
  title: info.value?.seo.title,
  description: info.value?.seo.description,
  referrer: "no-referrer",
});
</script>

<template>
  <div class="detail">
    <div class="page-body" >
    <div class="detail-box">
      <p class="detail-box-title">{{ info.title }}</p>
      <p class="detail-box-info m-flex-r m-jc-s m-ai-c">
        <span class="m-flex-r m-jc-s m-ai-c">
          <img
            v-if="info.author.avatarUrl"
            :src="info.author.avatarUrl"
            style="border-radius: 50%;width: 24px;height: 24px;"
            alt=""
          />
          <span style="margin-left: 8px;">{{ info.author.nickName }}</span>
        </span>
        <span class='iconfont lishixiao m-margin-right4' style="font-size:12px;"></span>
        <span v-if="info.updateTime">{{ info.updateTime }}</span>
        <span  style="margin-left: 16px;font-size:12px" class="iconfont yueduxiao m-margin-right4"> </span>
        <span style="margin-left: 8px;">{{ info?.viewsCount }}</span>
      </p>
      <div class="markdown-body" v-highlight v-if="info" v-html="info.content"></div>
    </div>
    <coms :coms="siteInfo.result.components"/>
  </div>
  </div>
</template>

<style lang="scss" scoped>

.detail {
  width: 100%;

  .page-body{
    width:100%;
    display:flex;
    flex-direction:column;
    @media (min-width: 1000px){
      width:1000px;
      flex-direction:row;
      margin:0 auto;
  }
}

  &-box {
    margin: 0 auto;
    max-width: 700px;
    padding: 24px;
    box-sizing: border-box;
    &-title {
      color: #252933;
      font-size: 30px;
      font-weight: 600;
    }
    &-info {
      margin: 8px 0;
      span {
        color: #969696;
        font-size: 13px;
        margin-right: 8px;
      }
    }
  }
}

.markdown-body{word-break:break-word;line-height:1.75;font-weight:400;font-size:16px;overflow-x:hidden;color:#252933}.markdown-body h1,.markdown-body h2,.markdown-body h3,.markdown-body h4,.markdown-body h5,.markdown-body h6{line-height:1.5;margin-top:35px;margin-bottom:10px;padding-bottom:5px}.markdown-body h1{font-size:24px;line-height:38px;margin-bottom:5px}.markdown-body h2{font-size:22px;line-height:34px;padding-bottom:12px;border-bottom:1px solid #ececec}.markdown-body h3{font-size:20px;line-height:28px}.markdown-body h4{font-size:18px;line-height:26px}.markdown-body h5{font-size:17px;line-height:24px}.markdown-body h6{font-size:16px;line-height:24px}.markdown-body p{line-height:inherit;margin-top:22px;margin-bottom:22px}.markdown-body img{max-width:100%}.markdown-body hr{border:none;border-top:1px solid #ddd;margin-top:32px;margin-bottom:32px}.markdown-body code{word-break:break-word;border-radius:2px;overflow-x:auto;background-color:#fff5f5;color:#ff502c;font-size:.87em;padding:.065em .4em}.markdown-body code,.markdown-body pre{font-family:Menlo,Monaco,Consolas,Courier New,monospace}.markdown-body pre{overflow:auto;position:relative;line-height:1.75}.markdown-body pre>code{font-size:12px;padding:15px 12px;margin:0;word-break:normal;display:block;overflow-x:auto;color:#333;background:#f8f8f8}.markdown-body a{text-decoration:none;color:#0269c8;border-bottom:1px solid #d1e9ff}.markdown-body a:active,.markdown-body a:hover{color:#275b8c}.markdown-body table{display:inline-block!important;font-size:12px;width:auto;max-width:100%;overflow:auto;border:1px solid #f6f6f6}.markdown-body thead{background:#f6f6f6;color:#000;text-align:left}.markdown-body tr:nth-child(2n){background-color:#fcfcfc}.markdown-body td,.markdown-body th{padding:12px 7px;line-height:24px}.markdown-body td{min-width:120px}.markdown-body blockquote{color:#666;padding:1px 23px;margin:22px 0;border-left:4px solid #cbcbcb;background-color:#f8f8f8}.markdown-body blockquote:after{display:block;content:""}.markdown-body blockquote>p{margin:10px 0}.markdown-body ol,.markdown-body ul{padding-left:28px}.markdown-body ol li,.markdown-body ul li{margin-bottom:0;list-style:inherit}.markdown-body ol li .task-list-item,.markdown-body ul li .task-list-item{list-style:none}.markdown-body ol li .task-list-item ol,.markdown-body ol li .task-list-item ul,.markdown-body ul li .task-list-item ol,.markdown-body ul li .task-list-item ul{margin-top:0}.markdown-body ol ol,.markdown-body ol ul,.markdown-body ul ol,.markdown-body ul ul{margin-top:3px}.markdown-body ol li{padding-left:6px}.markdown-body .contains-task-list{padding-left:0}.markdown-body .task-list-item{list-style:none}@media (max-width:720px){.markdown-body h1{font-size:24px}.markdown-body h2{font-size:20px}.markdown-body h3{font-size:18px}}

.markdown-body pre,.markdown-body pre>code.hljs{color:#333;background:#f8f8f8}.hljs-comment,.hljs-quote{color:#998;font-style:italic}.hljs-keyword,.hljs-selector-tag,.hljs-subst{color:#333;font-weight:700}.hljs-literal,.hljs-number,.hljs-tag .hljs-attr,.hljs-template-variable,.hljs-variable{color:teal}.hljs-doctag,.hljs-string{color:#d14}.hljs-section,.hljs-selector-id,.hljs-title{color:#900;font-weight:700}.hljs-subst{font-weight:400}.hljs-class .hljs-title,.hljs-type{color:#458;font-weight:700}.hljs-attribute,.hljs-name,.hljs-tag{color:navy;font-weight:400}.hljs-link,.hljs-regexp{color:#009926}.hljs-bullet,.hljs-symbol{color:#990073}.hljs-built_in,.hljs-builtin-name{color:#0086b3}.hljs-meta{color:#999;font-weight:700}.hljs-deletion{background:#fdd}.hljs-addition{background:#dfd}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:700}
</style>